---
title: Code
description: "`Code` is a component that represents a code block. By default, it renders a `code` element."
storybook: components-code--basic
source: components/code
style: components/code/code.style.ts
---

```tsx preview
<Code>console.log("Hello, Yamada!")</Code>
```

## Usage

:::code-group

```tsx [package]
import { Code } from "@yamada-ui/react"
```

```tsx [alias]
import { Code } from "@/components/ui"
```

```tsx [monorepo]
import { Code } from "@workspaces/ui"
```

:::

```tsx
<Code />
```

### Change Variant

```tsx preview
<VStack alignItems="flex-start">
  <For each={["solid", "subtle", "surface", "outline"]}>
    {(variant, index) => (
      <Code key={index} variant={variant}>
        console.log("Hello, Yamada!")
      </Code>
    )}
  </For>
</VStack>
```

### Change Size

```tsx preview
<VStack alignItems="flex-start">
  <For each={["xs", "sm", "md", "lg"]}>
    {(size, index) => (
      <Code key={index} size={size}>
        console.log("Hello, Yamada!")
      </Code>
    )}
  </For>
</VStack>
```

### Change Color Scheme

```tsx preview
<VStack alignItems="flex-start">
  <For each={["success", "warning"]}>
    {(colorScheme, index) => (
      <Code key={index} colorScheme={colorScheme}>
        console.log("Hello, Yamada!")
      </Code>
    )}
  </For>
</VStack>
```

## Props

<PropsTable name="code" />
